package org.brownflat.lighthouse.ci.bamboo;

import org.brownflat.lighthouse.ci.ConnectionException;
import org.brownflat.lighthouse.ci.HTTPServer;
import org.brownflat.lighthouse.ci.Monitorable;
import org.brownflat.lighthouse.ci.hudson.HudsonLatestBuildsRequest;

public class BambooServer extends HTTPServer implements Monitorable {

	public BambooServer(String host, int port) {
		super(host, port);		
	}
	
	@Override
	public boolean hasAnyBrokenBuilds() {
		BambooLatestBuildsRequest request = new BambooLatestBuildsRequest();
		String response = null;
		try {
			response = execute(request);
		} catch (ConnectionException e) {
			throw new RuntimeException(e);
		}
		return response.contains("class=\"Failed\"");
	}
}
